{extend name="$_admin_layout"}

{block name="tpl_vars"}
    {assign name="page_title" value="用户管理" /}
{/block}

{block name="main-content"}
    <form id="user_list" class="table-form table-manager">
        <div class="box box-blue no-heading">
            <div class="box-body">

                <div class="row">
                    <div class="col-sm-12">
                        <div class="table-fixed-toolbar">
                            {:helper('admin/toolbar')->render_button('新建', 'fa fa-plus', 'btn btn-primary form-get', array('url' => $_controller->url('create'), 'target-form' => 'user_form'))}
                            {:helper('admin/toolbar')->render_button('删除', 'fa fa-trash', 'btn btn-danger ajax-post selected disabled', array('url' => $_controller->url('bulk_delete'), 'target-form' => 'user_list', 'target-html' => 'user_list', 'confirm-text' => '确定删除选择的数据吗？'))}
                        </div>
                    </div>
                </div>

                <div class="row">
                    <div class="col-sm-12">
                        <table class="table table-bordered table-striped table-hover">
                            <thead>
                                <tr>
                                    <th class="list-ids">{:helper('admin/table')->render_header_select()}</th>
                                    <th>{:helper('admin/table')->render_header_text('ID')}</th>
                                    <th>{:helper('admin/table')->render_header_text('帐号')}</th>
                                    <th>{:helper('admin/table')->render_header_text('名称')}</th>
                                    <th>{:helper('admin/table')->render_header_text('用户组')}</th>
                                    <th>{:helper('admin/table')->render_header_text('电子邮箱')}</th>
                                    <th>{:helper('admin/table')->render_header_text('手机号')}</th>
                                    <th>{:helper('admin/table')->render_header_text('状态')}</th>
                                    <th>{:helper('admin/table')->render_header_text('操作')}</th>
                                </tr>
                            </thead>
                            <tbody>
                                {notempty name="user_list"}
                                    <?php $group_list = model('admin/group')->scope('enabled')->column('title', 'id'); ?>
                                    {foreach name="user_list" item="vo"}
                                        <tr>
                                            <td>{:helper('admin/table')->render_column_select($vo['id'], array('selected' => $selected))}</td>
                                            <td>{:helper('admin/table')->render_column_text($vo['id'])}</td>
                                            <td>{:helper('admin/table')->render_column_text($vo['username'])}</td>
                                            <td>{:helper('admin/table')->render_column_text($vo['nickname'])}</td>
                                            <td>{:helper('admin/table')->render_column_text($vo['gid'], ['list' => $group_list])}</td>
                                            <td>{:helper('admin/table')->render_column_text($vo['email'])}</td>
                                            <td>{:helper('admin/table')->render_column_text($vo['mobile'])}</td>
                                            <td>{:helper('admin/table')->render_column_status($vo['status'])}</td>
                                            <td>
                                                <?php if ($vo['id'] == 1): ?>
                                                    {:helper('admin/html')->render_span('默认管理员不允许修改', 'label label-default')}
                                                <?php else: ?>
                                                    {:helper('admin/table')->render_action('修改', 'fa fa-edit', 'btn btn-primary btn-xs form-get', array('url' => $_controller->url('modify', array('id' => $vo['id']))))}
                                                <?php endif; ?>
                                            </td>
                                        </tr>
                                    {/foreach}
                                {else /}
                                    {:helper('admin/table')->render_empty_row()}
                                {/notempty}
                            </tbody>
                        </table>

                        {notempty name="user_list"}
                            {:helper('admin/table')->render_paginationx($_controller->url('index', ['page' => '[page]']), $total_rows, $page_num, $page_size, $sort_field, $sort_order)}
                        {/notempty}
                    </div>
                </div>

            </div><!-- /.box-body -->
        </div><!-- /.box -->
    </form>
{/block}
